<#import "spring.ftl" as spring />
<#import "inspector-time-macros.ftl" as imacro />
<#setting number_format="0.##"/>

<html>
<head>
	<title>Schedule your inspection</title>
</head>
<body>

<script>
	/**
	 * Cleans up any values prior to passing them to server to be persisted
	 */
	function formatFieldValues() {
		//clean the listed price field
	    priceField = document.getElementById('inspection.property.listedPrice');
		priceField.value = cleanCurrency(priceField.value);	  
	}
</script>

<#include "inspectionDropDownValues.ftl" />
<#include "schedulebreadcrumb.ftl" />

<div id="content">

	<@imacro.listErrors "criteria" />
	
	<div id="infoBox">
	<table>
		<tr>
			<td><b>Home Inspector:</b></td>
			<td>${inspectorCompany.name}</td>
		</tr>
	</table>	
	</div>

	<p>Welcome!  You are just a few steps away from getting a price quote and reserving an inspection time.</p>
	
	<form name="scheduleForm"  method="POST" onsubmit="formatFieldValues()">
		<input type="hidden" name="requestedPage" id="requestedPage" value="" />
		<input type="hidden" name="requestedEvent" id="requestedEvent" value="" />

		
		<table class="formTable twoColForm">
			<tr>
				<td colspan="2"><h2>Primary Home Buyer</h2></td>
			</tr>
			<tr>
				<th><span class="required">*</span>First Name</th>
				<td><@spring.formInput "criteria.inspection.homeBuyer.name.first", 'size="25"' /></td>
			</tr>
			<tr>
				<th><span class="required">*</span>Last Name</th>
				<td><@spring.formInput "criteria.inspection.homeBuyer.name.last", 'size="25"' /></td>
			</tr>
			<tr>
				<th><span class="required">*</span>Email</th>
				<td><@spring.formInput "criteria.inspection.homeBuyer.email", 'size="25"' /></td>
			</tr>
			<tr>
				<th><span class="required">*</span>Contact Phone</th>
				<td><@spring.formInput "criteria.inspection.homeBuyer.phone",  'size="25"' /></td>
			</tr>
			<tr>
				<td colspan="2"><h2>Property Information</h2></td>
			</tr>
			<tr>
				<th><span class="required">*</span>Property Address</th>
				<td><@spring.formInput "criteria.inspection.property.location.street1",  'size="25"' /></td>
			</tr>
			<tr>
				<th><span class="required">*</span>City</th>
				<td><@spring.formInput "criteria.inspection.property.location.city",  'size="25"' /></td>
			</tr>
			<tr>
				<th><span class="required">*</span>State</th>
				<td>
					<@spring.bind "criteria.inspection.property.location.state" />
					 <select id="${spring.status.expression}" name="${spring.status.expression}">
				    	<option value=""<@spring.checkSelected ""/>>-- SELECT STATE --</option>
					    <#list states as option>
				    		<option value="${option}"<@spring.checkSelected option/>>${option.longName}</option>
				        </#list>
					</select>		
				</td>
			</tr>
			<tr>
				<th><span class="required">*</span>Zip</th>
				<td><@spring.formInput "criteria.inspection.property.location.zipCode", 'size="10"'/></td>
			</tr>
			<tr>
				<th><span class="required">*</span>Dwelling Type</th>
				<td><@imacro.enumDropDown "criteria.inspection.property.propertyType", propertyTypes /></td>
			</tr>
			<tr>
				<th><span class="required">*</span>Type of Foundation</th>
				<td><@imacro.enumDropDown "criteria.inspection.property.foundationType", foundationTypes /></td>
			</tr>
			<tr>
				<th><#if formValidator.isRequired("inspection.property.listedPrice", inspectorCompany)><span class="required">*</span></#if>Listing Price</th>
				<td>
					<@spring.bind "criteria.inspection.property.listedPrice" />
					<#if criteria.inspection.property.listedPrice == 0>							
						<input type="text" size="10" maxlength="13" name="${spring.status.expression}" value="" />
					<#else>
						<input type="text" size="10" maxlength="13" name="${spring.status.expression}" value="${spring.status.value?default("")}" />							
					</#if>	
				</td>
			</tr>
			<tr>
				<th><#if formValidator.isRequired("inspection.property.squareFeet", inspectorCompany)><span class="required">*</span></#if>Size in Square Feet <span class="labelSubtext">(some states only)</span></th>
				<td>
					<@spring.bind "criteria.inspection.property.squareFeet" />
					<#if criteria.inspection.property.squareFeet == 0>							
						<input type="text" size="10" maxlength="5" name="${spring.status.expression}" value="" />
					<#else>
						<input type="text" size="10" maxlength="5" name="${spring.status.expression}" value="${spring.status.value?default("")}" />							
					</#if>			
				</td>
			</tr>
			<tr>
				<th><#if formValidator.isRequired("inspection.property.numberOfBedrooms", inspectorCompany)><span class="required">*</span></#if>Number of Bedrooms</th>
				<td><@spring.formSingleSelect "criteria.inspection.property.numberOfBedrooms", beds /></td>
			</tr>
			<tr>
				<th><#if formValidator.isRequired("inspection.property.numberOfBathrooms", inspectorCompany)><span class="required">*</span></#if>Number of Bathrooms</th>
				<td><@spring.formSingleSelect "criteria.inspection.property.numberOfBathrooms", baths /></td>
			</tr>
		</table>
		
								

		<br style="clear:both">
		<div class="bottomNavLayout">
			<input type="submit" value="CONTINUE" class="navFwd" />
		</div>
		<br style="clear:both"/>

								
		<div class="requiredText">*INDICATES REQUIRED FIELDS</div>

	</form>
</div> <!-- /content -->
</body>
</html>